package com.wis.mapper;


import com.wis.entity.NoticeEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NoticeMapper {
    //1 显示公告信息,分页查询
    @Select("select id,name,content,time,state from notice order by time desc limit #{page},#{limit}")
    List<NoticeEntity> showNotice(@Param("page")int page, @Param("limit")int limit);

//    //2 根据id查询一条notice
//    @Select("select * from notice where id = #{id} and state = 1")
//    NoticeEntity showOneNotice(int id);

    // 3 统计notice数量
    @Select("select COUNT(1) from notice where state = 1 order by time desc")
    int showNoticeCount();

    //4 模糊查询notice
    @Select("SELECT * FROM notice WHERE name LIKE CONCAT('%', #{name}, '%')")
    List<NoticeEntity> findBlurry(@Param("name") String name);

    //5 删除
    @Delete("delete from notice where id = #{id}")
    int delNotice(int id);

    //6 更新
    @Update("update notice set name = #{name},content = #{content},time = #{time},state=#{state} where id = #{id}")
    int updateNotice(NoticeEntity notice);

    //7 新增
    @Insert("insert into notice (name,content,time,state) values (#{name},#{content},#{time},#{state})")
    int addNotice(NoticeEntity notice);


}


